package common.util;

import java.util.HashMap;

import medios.exceptions.MyException;


public class SortingBag {

	private static HashMap map = new HashMap();
	private static HashMap stMap = new HashMap();
	private int max;
	private int min;
	private static int length;
	private static int stLen;
	
	
	public SortingBag() {
		length = 0;
		stLen = 0;
		max = 0;
		min = -1;
	}
	
	private void calc(int item) {
		
		if( item > max ) max = item;
		if( item < min || min == -1) min = item;
	}
	
	public int getMax() {
		return max;
	}
	
	public int getMin() {
		return min;
	}
	
	public void put(int item) throws MyException {
		if(item <= 0) {
			return;
		}
		map.put(length, item);
		calc(item);
		length++;
	}
	
	public void put(String item) {
		if(item == null || item.equals("")) {
			return;
		}
		stMap.put(stLen, item);
		stLen++;
	}
	
	public void put(String[] items) {
		if(items == null) {
			return;
		}
		for(int i = 0 ; i < items.length ; i ++) {
			stMap.put(stLen, items[i]);
			stLen++;
		}
	}
	
	public String getRand1() {
		if(stLen == 0) {
			return "";
		}
		java.util.Random ran = new java.util.Random();
		int rand = ran.nextInt(stLen);
		return (String) stMap.get(rand);
	}
	
	
}
